// pages/deduction_money/deduction_money.js
var app = getApp();
var ApiUrl = app.globalData.ApiUrl;

Page({

  /**
   * 页面的初始数据1
   */
  data: {
    point:0,
    signin_list:[]
  },
  deductionAccount(){
      let that = this;
      let k = wx.getStorageSync('key');
      //index.php?act=other_member&op=get_replace_money_info
      wx.request({
        url: ApiUrl + 'index.php?act=other_member&op=get_replace_money_info',
        data: {
          key: k
        },
        header: {
          'content-type': 'application/x-www-form-urlencoded'
        },
        method: 'POST',
        success: function (result) {
          console.log('抵扣金账户:==>', result);
          if (result.statusCode == 200) {
            if (result.data.code == 200) {
              console.log(result.data.datas);
              let res = result.data.datas.info.money;

              that.setData({
                point: res
              })
              
            }
          }
        }
      });
  },
  duihuan_btn(){
    let that = this;
    let k = wx.getStorageSync('key');
    //index.php?act=other_member&op=replace_to_points
    wx.request({
      url: ApiUrl + 'index.php?act=other_member&op=replace_to_points',
      data: {
        act:'other_member',
        op:'replace_to_points',
        key: k
      },
      header: {
        'content-type': 'application/x-www-form-urlencoded'
      },
      method: 'POST',
      success: function (result) {
        console.log('抵扣金兑换为牧草:==>', result);
        if (result.statusCode == 200) {
          if (result.data.code == 200) {
            console.log(result.data.datas);
            let res = result.data.datas;
            that.replace_io();
          }
        }
      }
    });
  },
  //index.php?act=other_member&op=replace_io
  replace_io(){
    let that = this;
    let k = wx.getStorageSync('key');
    //index.php?act=other_member&op=replace_to_points
    wx.request({
      url: ApiUrl + 'index.php?act=other_member&op=replace_io',
      data: {
        key: k,
        page: 1,
        size: 10
      },
      header: {
        'content-type': 'application/x-www-form-urlencoded'
      },
      method: 'POST',
      success: function (result) {
        console.log('抵扣金兑换明细:==>', result);
        if (result.data.code == 200) {
          console.log(result.data.datas);
          let res = result.data.datas;
          that.setData({
            signin_list: res
          })
        }
      }
    });
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.deductionAccount();
    this.replace_io();
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    this.deductionAccount();
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})